package com.csun.dsms.service.impl;

import com.csun.dsms.comment.base.enums.ErrorCodeEnum;
import com.csun.dsms.comment.core.support.BaseService;
import com.csun.dsms.comment.core.support.CsunMessageSource;
import com.csun.dsms.mapper.DsmsRoleUserMapper;
import com.csun.dsms.model.domain.DsmsRoleUser;
import com.csun.dsms.service.DsmsRoleUserService;
import com.google.common.base.Preconditions;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author chisj chisj@foxmail.com
 * @version 1.0.0
 * @date 2021-09-01 13:23
 * @description: TODO
 */
@Service
@Transactional
public class DsmsRoleUserServiceImpl extends BaseService<DsmsRoleUser> implements DsmsRoleUserService {

    @Resource
    private DsmsRoleUserMapper dsmsRoleUserMapper;
    @Resource
    private CsunMessageSource csunMessageSource;


    /**
     * 用户是否绑定该角色.
     *
     * @param userId    the user id
     * @param roleId    the role id
     *
     * @return  the dsms role user.
     */
    @Override
    public DsmsRoleUser getByUserIdAndRoleId(Long userId, Long roleId) {

        Preconditions.checkArgument(userId != null,
                csunMessageSource.getMessage("user.id.null", null));

        Preconditions.checkArgument(roleId != null,
                csunMessageSource.getMessage("role.id.null", null));

        return dsmsRoleUserMapper.getByUserIdAndRoleId(userId, roleId);
    }

    @Override
    public List<DsmsRoleUser> listByRoleIdList(List<Long> roleIdList) {
        return null;
    }

    @Override
    public Integer deleteByRoleIdList(List<Long> roleIdList) {
        return null;
    }
}
